473,418 Members | 2,142 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

Drop Down Menu.

71
I have a javascript drop down menu that I borrowed from a website. It utilizes a little .css to help with formatting. The menu works great, and on all 3 of the browsers I'm concerned about; but I am having one problem.

The menu, as designed, is a 1-tier menu (or is it 2-tier). It has the horizontal menu bar, along with the drop downs... but the drop downs aren't designed to propogate another menu (3rd teir). I was wondering if, but looking at the code I've got, anyone could see a *relatively* easy way to make this menu a three tier:

Here's the code:
Expand|Select|Wrap|Line Numbers
  1. /***********************************************
  2. * AnyLink Drop Down Menu- © Dynamic Drive (www.dynamicdrive.com)
  3. * This notice MUST stay intact for legal use
  4. * Visit http://www.dynamicdrive.com/ for full source code
  5. ***********************************************/
  6.  
  7. //Contents for Ministries Menu
  8. var menu1=new Array()
  9. menu1[0]='<a href="#" onclick="return clickreturnvalue()" onmouseover="dropdownmenu(this, event, menu2, '150px')" onmouseout="delayhidemenu()">Worship</a>'
  10. menu1[1]='<a href="/fellowship.shtml">Fellowship</a>'
  11. menu1[2]='<a href="/outreach.shtml">Outreach</a>'
  12. menu1[3]='<a href="#" onclick="return clickreturnvalue()" onmouseover="dropdownmenu(this, event, menu3, '150px')" onmouseout="delayhidemenu()">Discipleship</a>'
  13. menu1[4]='<a href="/care.shtml">Care</a>'
  14. menu1[5]='<a href="#" onclick="return clickreturnvalue()" onmouseover="dropdownmenu(this, event, menu4, '150px')" onmouseout="delayhidemenu()">Youth/Children</a>'
  15.  
  16. //Contents for Worship Menu
  17. var menu2=new Array()
  18. menu2[0]='<a href="/choir.shtml">Choir</a>'
  19.  
  20. //Contents for Discipleship Menu
  21. var menu3=new Array()
  22. menu2[0]='<a href="/smallGroup.shtml">Small Groups</a>'
  23. menu2[1]='<a href="/sunSchool.shtml">Sunday School</a>'
  24.  
  25. //Contents for Youth/Children
  26. var menu4=new Array()
  27. menu2[0]='<a href="/youth.shtml">Middle/High School</a>'
  28. menu2[1]='<a href="/children.shtml">Preschool/Children</a>'
  29.  
  30. //Contents for Resources
  31. var menu5=new Array()
  32. menu2[0]='<a href="/message.shtml">Message Board</a>'
  33. menu2[1]='<a href="/links.shtml">Links</a>'
  34.  
  35. //Declare Menu variables
  36. var menuwidth='165px' //default menu width
  37. var menubgcolor='#3B3B65'  //menu bgcolor
  38. var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
  39. var hidemenu_onclick="yes" //hide menu when user clicks within menu?
  40.  
  41. /////No further editting needed
  42.  
  43. var ie4=document.all
  44. var ns6=document.getElementById&&!document.all
  45.  
  46. if (ie4||ns6)
  47. document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')
  48.  
  49. function getposOffset(what, offsettype){
  50. var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
  51. var parentEl=what.offsetParent;
  52. while (parentEl!=null){
  53. totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
  54. parentEl=parentEl.offsetParent;
  55. }
  56. return totaloffset;
  57. }
  58.  
  59.  
  60. function showhide(obj, e, visible, hidden, menuwidth){
  61. if (ie4||ns6)
  62. dropmenuobj.style.left=dropmenuobj.style.top="-500px"
  63. if (menuwidth!=""){
  64. dropmenuobj.widthobj=dropmenuobj.style
  65. dropmenuobj.widthobj.width=menuwidth
  66. }
  67. if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
  68. obj.visibility=visible
  69. else if (e.type=="click")
  70. obj.visibility=hidden
  71. }
  72.  
  73. function iecompattest(){
  74. return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
  75. }
  76.  
  77. function clearbrowseredge(obj, whichedge){
  78. var edgeoffset=0
  79. if (whichedge=="rightedge"){
  80. var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
  81. dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
  82. if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
  83. edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
  84. }
  85. else{
  86. var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
  87. var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
  88. dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
  89. if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
  90. edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
  91. if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
  92. edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
  93. }
  94. }
  95. return edgeoffset
  96. }
  97.  
  98. function populatemenu(what){
  99. if (ie4||ns6)
  100. dropmenuobj.innerHTML=what.join("")
  101. }
  102.  
  103.  
  104. function dropdownmenu(obj, e, menucontents, menuwidth){
  105. if (window.event) event.cancelBubble=true
  106. else if (e.stopPropagation) e.stopPropagation()
  107. clearhidemenu()
  108. dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
  109. populatemenu(menucontents)
  110.  
  111. if (ie4||ns6){
  112. showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
  113. dropmenuobj.x=getposOffset(obj, "left")
  114. dropmenuobj.y=getposOffset(obj, "top")
  115. dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
  116. dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
  117. }
  118.  
  119. return clickreturnvalue()
  120. }
  121.  
  122. function clickreturnvalue(){
  123. if (ie4||ns6) return false
  124. else return true
  125. }
  126.  
  127. function contains_ns6(a, b) {
  128. while (b.parentNode)
  129. if ((b = b.parentNode) == a)
  130. return true;
  131. return false;
  132. }
  133.  
  134. function dynamichide(e){
  135. if (ie4&&!dropmenuobj.contains(e.toElement))
  136. delayhidemenu()
  137. else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
  138. delayhidemenu()
  139. }
  140.  
  141. function hidemenu(e){
  142. if (typeof dropmenuobj!="undefined"){
  143. if (ie4||ns6)
  144. dropmenuobj.style.visibility="hidden"
  145. }
  146. }
  147.  
  148. function delayhidemenu(){
  149. if (ie4||ns6)
  150. delayhide=setTimeout("hidemenu()",disappeardelay)
  151. }
  152.  
  153. function clearhidemenu(){
  154. if (typeof delayhide!="undefined")
  155. clearTimeout(delayhide)
  156. }
  157.  
  158. if (hidemenu_onclick=="yes")
  159. document.onclick=hidemenu
  160.  
  161. And on the shtml page:
  162.  
  163. <table width="900px" border="1" cellspacing="0" cellpadding="0">
  164. <tr>
  165. <td align="center">
  166.     <a href="/default.shtml">Home</a>
  167. </td>
  168. <td align="center">
  169.     <a href="default.shtml" onClick="return clickreturnvalue()" onMouseOver="dropdownmenu(this, event, menu1, '150px')" onMouseOut="delayhidemenu()">Ministries</a>
  170. </td>
  171. <td align="center">
  172.     <a href="/calendar.shtml">Calendar</a>
  173. </td>
  174. <td align="center">
  175.     <a href="/about.shtml">About</a>
  176. </td>
  177. <td align="center">
  178.     <a href="/contact.shtml">Contact Us</a>
  179. </td>
  180. <td align="center">
  181.     <a href="#" onClick="return clickreturnvalue()" onMouseOver="dropdownmenu(this, event, menu5, '150px')" onMouseOut="delayhidemenu()">Resources</a>
  182. </td>
  183. </tr>
  184. </table>
  185.  
  186. And the .css:
  187.  
  188. #dropmenudiv{
  189. position:absolute;
  190. border:1px solid black;
  191. border-bottom-width: 0;
  192. font:normal 12px Verdana;
  193. line-height:18px;
  194. z-index:100;
  195. }
  196.  
  197. #dropmenudiv a{
  198. width: 100%;
  199. display: block;
  200. text-indent: 3px;
  201. border-bottom: 1px solid black;
  202. padding: 1px 0;
  203. text-decoration: none;
  204. font-weight: bold;
  205. }
  206.  
  207. #dropmenudiv a:hover{ /*hover background color*/
  208. background-color: #7AD0E1;
  209. }
  210.  
Oct 27 '06 #1
3 4430
rsteph
71
Here's a link to the page with this menu on it:

http://rsteph49.tripod.com/default2.shtml

And here's one with a different dropdown menu. (I actually like this menu, but it doesn't come out right in FireFox, and I haven't been able to get it fixed):

http://rsteph49.tripod.com/default.shtml
Oct 27 '06 #2
rsteph
71
Anyone have any thoughts on this?
Oct 30 '06 #3
AricC
1,892 Expert 1GB
For an easy fix could use this menu instead:

DD
Oct 30 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Haines Brown | last post by:
I've implemented the horizontal drop down menu discussed recently in this newsgroup, and it works nicely under Galeon and Mozilla, but not IE 5.0. Here are the problems: Under IE 5.0, the...
4
by: rajat | last post by:
Hi, I have adapted a drop down menu from USC webpage (www.usc.edu). The link to my page is http://www-scf.usc.edu/~swarup/test/test.html The links to the CSS ans JS files are:...
2
by: hemanth.singamsetty | last post by:
Hello there, I've a drop down menu (created using CSS & Javascript -- see code below). My problem is, whenever I click a link on the menu the new page replaces the current page (and the menu...
3
by: Reb | last post by:
Hi, I am using drop down menu in my pages. In one of my page,there is a listbox control below the menu. This listbox control is hiding the drop down menu items. How can i make the drop down...
1
by: phpnewb | last post by:
Hi, I know i'm doing it wrong, but I'm using a while loop right now to create several instances of a drop down menu. It gives me undesirable results. Can you tell me the right way to do it. Below are...
4
by: TycoonUK | last post by:
Hi, As I do not have IE7 on my computer, I was wondering if there is a fault in my CSS Menu when using IE7. Please can someone look at my site - http://www.worldofmonopoly.co.uk and tell me...
1
by: Kaland | last post by:
Do the search engines follow links that are within forms (like the drop-down menu) so that those pages are indexed? Here is the code for a sample drop-down menu that I created. <form><select...
22
by: Archanak | last post by:
Hi, I am using 2-level CSS Drop Down Menu in my perl/CGI program. here is the code. #!c:/perl/bin/perl.exe use CGI qw(:standard);
0
by: buzzard724 | last post by:
Ul li drop down menu works in FF not quite in IE Thank you for looking at this. The page is generated dynamically by php, js and jquery. The drop down menu ul- reports-li - works fine in FF. In...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.